//
//  CustomFlutterController.swift
//  BoostTestIOS
//
//  Created by 张海南 on 2023/4/17.
//

import UIKit
import flutter_boost

class CustomFlutterController: UIViewController {
    
    lazy var flutterVC = FBFlutterViewContainer()

    override func viewDidLoad() {
        super.viewDidLoad()
        setupUI()
    }
    
    func setupUI() {
        guard let flutterVC = self.flutterVC else { return }
        addChild(flutterVC)
        view.addSubview(flutterVC.view)
        flutterVC.view.frame = view.bounds

        BoostDelegate.shared.navigationController = self.navigationController as? MainNavigationController
    }

    func configFlutter(name: String, uniqueId: String?, params: [AnyHashable: Any]?, opaque: Bool) {
        flutterVC?.setName(name, uniqueId: uniqueId, params: params, opaque: opaque)
    }

    deinit {
        print("deinit - CustomFlutterController")
        flutterVC?.removeFromParent()
    }

}
